// JavaScript Document


Date.prototype.format = function(format)  
{  
   var o = {  
     "M+" : this.getMonth()+1, //month  
     "d+" : this.getDate(),    //day  
     "h+" : this.getHours(),   //hour  
     "m+" : this.getMinutes(), //minute  
     "s+" : this.getSeconds(), //second  
     "q+" : Math.floor((this.getMonth()+3)/3), //quarter  
     "S" : this.getMilliseconds() //millisecond  
   }  
   if(/(y+)/.test(format)) format=format.replace(RegExp.$1,  
     (this.getFullYear()+"").substr(4 - RegExp.$1.length));  
   for(var k in o)if(new RegExp("("+ k +")").test(format))  
     format = format.replace(RegExp.$1,  
       RegExp.$1.length==1 ? o[k] :   
         ("00"+ o[k]).substr((""+ o[k]).length));  
   return format;  
}

/**
 * description : 得到字符串的字节长度;
 * @author yangzy;
 * @version 0.2;
 * @return 返回字符串的字节长度(eg:"一二12"的字节长度是6);
 */
String.prototype.getLength=function(){
 var text=this.replace(/[^\x00-\xff]/g,"**");
 return text.length;
}
/**
 * description : 按字节长度截取字符串,并添加后缀.
 * @author yangzy;
 * @version 0.3;
 * @param len 需要截取的长度,字符串长度不足返回本身;
 * @param alt 添加后缀(非必要),默认为"......";和 "javascript按字节长度截取字符串,并添加后缀. " 有关的java编程小帖士：

strong>Message.msg

指定消息表示符。

语法

public int msg;
 
 * @return 返回截取后的字符串;
 * @requires getlength;
 */
String.prototype.getShortForm=function(len,alt){
	
 var tempstr=this;

 if(this.getLength()>len)
 {
    if(!alt) 
	{
	   alt="...";

    }
    var i=0;

    for(var z=0;z<len;z++)
    {

      if(tempstr.charCodeAt(z)>255){
		  i=i+2;
		}
		else
		{
		   i=i+1;
		}
		if(i>=len)
		{
			tempstr=tempstr.slice(0,(z + 1))+alt;

			 break;
		}
	  }


   return tempstr;
 }else{

  return this+"";
 }
} 



String.prototype.trim = function()
{
    return this.replace(/(^[\\s]*)|([\\s]*$)/g, "");
}





Object.prototype.deep_clone = function(){  
    eval("var tmp = " + this.toJSON());  
    return tmp;  
}  
Object.prototype.toJSON = function(){  
    var json = [];  
	
    for(var i in this){  
        if(!this.hasOwnProperty(i)) continue;  
        //if(typeof this[i] == "function") continue;  
        json.push(  
            i.toJSON() + " : " +  
            ((this[i] != null) ? this[i].toJSON() : "null")  
        )  
    }  
    return "{\n " + json.join(",\n ") + "\n}";  
}  
Array.prototype.toJSON = function(){  
    for(var i=0,json=[];i<this.length;i++)  
        json[i] = (this[i] != null) ? this[i].toJSON() : "null";  
    return "["+json.join(", ")+"]"  
}  
  
String.prototype.toJSON = function(){  
    return '"' +  
        this.replace(/(\\|\")/g,"\\$1")  
        .replace(/\n|\r|\t/g,function(){  
            var a = arguments[0];  
            return  (a == '\n') ? '\\n':  
                    (a == '\r') ? '\\r':  
                    (a == '\t') ? '\\t': ""  
        }) +  
        '"'  
}  
Boolean.prototype.toJSON = function(){return this}  
Function.prototype.toJSON = function(){return this}  
Number.prototype.toJSON = function(){return this}  
RegExp.prototype.toJSON = function(){return this}  
  
// strict but slow  
String.prototype.toJSON = function(){  
    var tmp = this.split("");  
    for(var i=0;i<tmp.length;i++){  
        var c = tmp[i];  
        (c >= ' ') ?  
            (c == '\\') ? (tmp[i] = '\\\\'):  
            (c == '"')  ? (tmp[i] = '\\"' ): 0 :  
        (tmp[i] =   
            (c == '\n') ? '\\n' :  
            (c == '\r') ? '\\r' :  
            (c == '\t') ? '\\t' :  
            (c == '\b') ? '\\b' :  
            (c == '\f') ? '\\f' :  
            (c = c.charCodeAt(),('\\u00' + ((c>15)?1:0)+(c%16)))  
        )  
    }  
    return '"' + tmp.join("") + '"';  
}  

Date.prototype.format = function(format){
 /*
  * eg:format="yyyy-MM-dd hh:mm";
  */
 var o = {
  "M+" :  this.getMonth()+1,  //month
  "d+" :  this.getDate(),     //day
  "h+" :  this.getHours(),    //hour
      "m+" :  this.getMinutes(),  //minute
      "s+" :  this.getSeconds(), //second
      "q+" :  Math.floor((this.getMonth()+3)/3),  //quarter
      "S"  :  this.getMilliseconds() //millisecond
   }
  
   if(/(y+)/.test(format)) {
    format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
   }
 
   for(var k in o) {
    if(new RegExp("("+ k +")").test(format)) {
      format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
    }
   }
 return format;
}


/*
*	定义key
*/
var KEY = {
	key : {
		0x0:'KEY_0',
		0x1:'KEY_1',
		0x2:'KEY_2',
		0x3:'KEY_3',
		0x4:'KEY_4',
		0x5:'KEY_5',
		0x6:'KEY_6',
		0x7:'KEY_7',
		0x8:'KEY_8',
		0x9:'KEY_9',
		0xA:'KEY_UP',
		0xB:'KEY_DOWN',
		0xC:'KEY_LEFT',
		0xD:'KEY_RIGHT',
		0xE:'KEY_OK',
		0xF:'KEY_POWER',
		0x10:'KEY_PLAY',	//播放/暂停
		0x11:'KEY_RETURN',
		0x12:'KEY_REFRESH',	//刷新
		0x13:'KEY_CONFIG',
		0x14:'KEY_FAST',	//下一页
		0x15:'KEY_SLOW',	//上一页
		0x16:'KEY_BACK',	
		0x17:'PLAY_BACK_LOAD',
		0x18:'KEY_HOME',		//首页
		0x19:'KEY_COMBO',
		0x1a:'KEY_MUTE',
		0x1b:'KEY_VOL_A',		//音量加
		0x1c:'KEY_VOL_P',		//音量减
		0x1d:'KEY_CH_A',		//频道加
		0x1e:'KEY_CH_P',		//频道减
		0x1f:'KEY_POWER',		//KEY_POWER_EX
		0x26:'KEY_EPG',
		0x27:'KEY_SLOW_PLAY',		//慢进
		0x28:'KEY_PLAY_STOP',		//播放/暂停
		0x29:'KEY_FAST_PLAY',		//快进
		0x2A:'KEY_VCR',			//视频录制
		0x2B:'KEY_TV',			//直接进入tv
		0x2C:'KEY_VOD',			//进入电影点播
		0x2D:'KEY_FILE',		//本地文件
		0x2E:'KEY_SETTING',		//直接进入设置页面
	},
	PRESS:true,				//可以用来设置是否屏蔽掉事件,如正在请求外部页面的时候,在页面请求完成前,这段时间内不希望用户操作,可以将其设成false,对返回键不起作用
	CURTYPE:'',				//当前键盘的控制类型
	KEYBOARD:'',			//当前按键对应的名称,如按了0x14,KEYBOARD的值为,KEY_FAST
	PRESSTIME:0,			//按键触发时间
	TYPE:{},				//函数集
}


//定义keyRecv函数
function keyRecv(key){ 
	KEY.KEYBOARD = KEY.key[key];
	if(KEY.PRESSTIME){
		var date = new Date();
		KEY.PRESSTIME = date.getTime();
	}
	if(KEY.KEYBOARD == "KEY_POWER"){			//如果是关机事件
		if(config.isAli){
			var Fb = new JFB (0); 
			Fb.Hide();
			standBy();
			return ;
		}else{
			return KEY.shutDown();
		}
	}
	if(KEY.KEYBOARD == "KEY_HOME"){
		KEY.KEY_HOME();
		return false;
	}
	
	if(KEY.CURTYPE && KEY.TYPE[KEY.CURTYPE]){		//当前键盘类型不为空,使用对应的键函数
		return KEY.TYPE[KEY.CURTYPE](key,KEY.KEYBOARD);
	}else{
		return KEY.defaultAction(key,KEY.KEYBOARD);
	}
}

//定义键盘的默认事件
KEY.defaultAction =function(key){
	if(key!=0x11){		//如果键不是返回键
		if(KEY.PRESS && key!=0x11){
			if(KEY[KEY.KEYBOARD]){
				var bo = KEY[KEY.KEYBOARD]();
				return bo!==false;
			}else{
				return true;
			}
		}
	}else{
		if(KEY[KEY.KEYBOARD] ){
			var bo = KEY[KEY.KEYBOARD]();
			return bo!==false;
		}
	}
}


//当类型是ipBOX时,
KEY.TYPE['ipbox'] = function(key){
	if( key>=0x0 && key<=0x9){
		var a = document.activeElement;
		$.setIpAValue(a,key);
		return true;
	}else{
		return KEY.defaultAction(key);
	}
}

//数字输入
KEY.TYPE['numberInput'] = function(key){
	if( key>=0x0 && key<=0x9){			//0-9
		var a = document.activeElement;
		var val = a.getAttribute('val');
		var type = a.getAttribute('type');
		if(!type){type = '';}
		if(!val) val = '';
		
		val +=''+key;
		
		if(type=='password'){
			var pval = '';
			for(var i = 0;i<val.length;i++){
				pval +='*';
			}
			a.innerHTML = pval+'_';
		}else{
			a.innerHTML = val+'_';
		}
		a.setAttribute('val',val);
		
		document.refresh();
		return false;
	}else if(key ==0xC){		//向左,删除数字
		var a = document.activeElement;
		var val = a.getAttribute('val');
		var type = a.getAttribute('type');
		if(!type){type = '';}
		if(!val) val = '';
		if(val.length >0){
			val = val.substring(0,val.length - 1);
			if(type=='password'){
				var pval = '';
				for(var i = 0;i<val.length;i++){
					pval +='*';
				}
				a.innerHTML = pval+'_';
			}else{
				a.innerHTML = val+'_';
			}
			a.setAttribute('val',val);
			document.refresh();
			return false;
		}else{
			return true;
		}
	}else if(key == 0xD){
		return false;
	}else if(key == 0x11){		//如果是返回键
		if(KEY.TYPE['numberInput'].keyReturn){
			KEY.TYPE['numberInput'].keyReturn();
		}
	}else{
		return KEY.defaultAction(key);
	}
}

KEY.TYPE['shutdown'] = function(key){
	if(key == 0x11){
		var backButton = document.getElementById('backButton');
		backButton.click();
		return false;
	}else if(key == 0xC){		//left
		var id = document.activeElement.id;
		if(id == 'sleepButton'){
			document.focus('backButton');
			return false;
		}
	}else if(key == 0xD){		//right
		var id = document.activeElement.id;
		if(id == 'backButton'){
			document.focus('sleepButton');
			return false;
		}
	}
	return true;	
}

KEY.KEY_HOME = function(){
	$.gotoIndexPage();
}

var lastActiveA = null;
KEY.shutDown = function(){
	if(KEY.CURTYPE!="shutdown"){
		showShutDownWindow();
	}else{
		var a = document.getElementById('shutdownButton');
		a.click();
	}
	return true;
}
function showShutDownWindow(){
	if(!this.hasInit){
		initShutDownWindow();
		this.hasInit = true;
	}
	lastActiveA = document.activeElement;
	var shutDownWindow = document.getElementById('shutDownWindow');
	shutDownWindow.style.display = 'block';
	
	
	document.focus('shutdownButton');
}
function focusShutdown(event){
	var a = event.currentTarget;
	var par = a.parentNode;
	var tar = a.getAttribute('tar');
	KEY.CURTYPE='shutdown';
	par.className = 'shutDown_'+tar+'_h';
}

function blurShutdown(event){
	var a = event.currentTarget;
	var par = a.parentNode;
	var tar = a.getAttribute('tar');
	
	par.className = 'shutDown_'+tar+'_l';
}

function clickShutdown(event){
	var a = event.currentTarget;
	var tar = a.getAttribute('tar');
	
	if(tar == 'sleep'){
		KEY.PRESS = false;
		var mLed = new jsLedMgr();
		mLed.jsCtrlAllLight(0);
		mLed.jsCtrlLightDigit(0,'-');
		mLed.jsCtrlLightDigit(1,'-');
		mLed.jsCtrlLightDigit(2,'-');
		mLed.jsCtrlLightDigit(3,'-');
		mLed.jsCtrlLightDigit(4,'-');
		mLed.jsCtrlLightDigit(5,'-');
		
		var shutdownTip = document.getElementById('shutdownTip');
		shutdownTip.innerHTML = lang.shutdown.rebooting;
		shutdownTip.style.display = 'block';
		mReboot();
	}else if(tar == 'back'){
		KEY.CURTYPE = KEY.OLDTYPE;
		if(lastActiveA){
			lastActiveA.focus();
		}
		var shutDownWindow = document.getElementById('shutDownWindow');
		shutDownWindow.style.display = 'none';
	}else if(tar == 'off'){
		KEY.PRESS = false;
		var mLed = new jsLedMgr();
		mLed.jsCtrlAllLight(0);
		mLed.jsCtrlLightDigit(0,'-');
		mLed.jsCtrlLightDigit(1,'-');
		mLed.jsCtrlLightDigit(2,'-');
		mLed.jsCtrlLightDigit(3,'-');
		mLed.jsCtrlLightDigit(4,'-');
		mLed.jsCtrlLightDigit(5,'-');
		
		var shutdownTip = document.getElementById('shutdownTip');
		shutdownTip.innerHTML = lang.shutdown.shutdowning;
		shutdownTip.style.display = 'block';
		
		shutdown();
	}
}

function initShutDownWindow(){
	$.template("shutDownWindow","jst_shutDownWindow",lang.shutdown);
	var shutDownItemList = document.getElementById('shutDownItemList');
	var aList = shutDownItemList.getElementsByTagName('a');
	var a;
	for(var i = 0;i<aList.length;i++){
		a = aList[i];
		a.onfocus = focusShutdown;
		a.onblur = blurShutdown;
		a.onclick = clickShutdown;
	}
}

//常用工具
var $={	
	id:function(id){
		return document.getElementById(id);
	},
	addSNToURL:function(url){
		var _sn = mGetPeerid();
		if(url.indexOf('?')>0){
			return url+'&sn='+_sn;
		}else{
			return url+'?sn='+_sn;
		}
	},
	log:function(l){
		alert('##############################::'+l);
	},
	gotoIndexPage:function(){
		var url = '';
		url = config.indexUrl;
		
		this.gotoPage(url);
		return false;
		
	},
	getDisNumber:function(n){
		var p = parseInt(n/100);
		n = n%100;
		var p2 = parseInt(n/10);
		var p3 = n%10;
		return ''+p+p2+p3;
	},
	gotoPage:function(url){
		document.location.replace(url);
	},
	getImageUrl:function(url,defaultUrl){
		if(url && url.indexOf('http') > -1){
			return url
		}else{
			if(!url && defaultUrl){
				return defaultUrl;
			}else if(url){
				
				if(url.indexOf('/') == 0){
					return config.webUrl+url;
				}else{
					return url;
				}
			}else{
				return "";
			}
		}
	},
	ajax:function(param) 
	{
		
		if(param.type==null)
		{
			param.type = "GET";
		}
		if(param.global==true)
		{
			var xmlHttp=new XMLHttpRequest(1);
		}
		else
		{
			var xmlHttp=new XMLHttpRequest();
		}
		if(param.timeOut){
			xmlHttp.timeOut(param.timeOut);
		}
		if(param.header){
			for(var i= 0;i<param.header.length;i++){
				xmlHttp.setRequestHeader(param.header[i].name,param.header[i].value);
			}
		}
		xmlHttp.onreadystatechange=function(){			
			if(xmlHttp.readyState == 4){	
				if (xmlHttp.status==200){			//处理成功
					
					if(param.dataType=="json"){	
						var data;
						try{
							eval("data = "+xmlHttp.responseText);
						}catch (e){
							if(param.error!=null)
							{
								param.error(-1,xmlHttp.statusMsg);		//当作状态不存在
							}
						}
						param.success(data);
					}else{
						param.success(xmlHttp.responseText);
					}					
				}else{
					
					if(param.error!=null)
					{
						param.error(xmlHttp.status,xmlHttp.statusMsg);
					}
				}
				
			 }
		};
		if(param.agentIp && param.agentPort){
			xmlHttp.open(param.type,param.url,true,param.agentIp,parseInt(param.agentPort));
		}else{
			xmlHttp.open(param.type,param.url,true);
		}
		xmlHttp.send(null);

	},
	template:function(divId,templateId,data)
	{
		var result = TrimPath.processDOMTemplate(templateId, data);
		
		document.getElementById(divId).innerHTML= result;
	},
	mCon:new mConfig(),
	getConfigNumberValue:function(key,defaultValue){
		var v = this.getConfigValue(key,defaultValue);
		return parseInt(v);
	},
	getConfigValue:function(key,defaultValue){
		return this.getConfigPathValue(config.configPath,key,defaultValue);
	},
	getConfigPathValue:function(path,key,defaultValue){	
		var value = this.mCon.getConfigValue(path,key);alert(key+"value:"+value);
		if(value==null)
		{
			if(defaultValue==null)
			{
				value = "";
			}
			else
			{
				value = defaultValue;
			}
		}
		return value;
	},
	setConfigValue:function(key,value){
		this.setConfigPathValue(config.configPath,key,value);
	},
	setConfigPathValue:function(path,key,value){
		this.mCon.setConfigValue(path,key,String(value));
	},
	getIp:function(){
		var ip = null;
		
		var ppp0 = mSTB.getLocalIp('ppp0');		//
		var eth0 = mSTB.getLocalIp('eth0');		//
		var rausb0 = mSTB.getWifiIp(); //
		var rausb0 = '';
		if(ppp0){
			ip = ppp0;
		}else if(eth0){
			ip = eth0;
		}else if(rausb0){
			ip = rausb0;
		}
		return ip;
	},
	checkIp:function(ip){
		var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){3}$/;
		if(ip && ip.match(reg)){
			return true;
		}else{
			return false;
		}
	},
	checkEmail:function(str){
		var reg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
		return reg.test(str);
	},
	initIpBox:function(boxId,value,focus){
		var box = document.getElementById(boxId);
		var con = '';
		var ipExits = false;
		var ipArray;
		var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){3}$/;
		if(value && value.match(reg)){
			ipExits = true;
			ipArray = value.split('.');
		}
		con +='<div class="ipContentBox">';
		for(var i=0;i<4;i++){
			var j = i + 1;
			if(ipExits){
				con+='<div class="ipBox"><a href="#" pos="'+j+'" val="'+ipArray[i]+'">'+ipArray[i]+'</a></div>';
			}else{
				con+='<div class="ipBox"><a href="#" pos="'+j+'" val="">&nbsp;</a></div>';
			}
		}
		con += '</div>';
		box.innerHTML = con;
		
		var aList = box.getElementsByTagName('a');
		var a;
		for(var i=0;i<aList.length;i++){
			a = aList[i];
			a.onfocus = $.focusIpA;
			a.onblur = $.blurIpA
		}
		
		if(focus){
			aList[0].focus();
		}
	},
	setIPFocusFromBox:function(boxId){
		var box = document.getElementById(boxId);
		var aList = box.getElementsByTagName('a');
		aList[0].focus();
	},
	getIpAValueFromBox:function(boxId){
		var box = document.getElementById(boxId);
		var aList = box.getElementsByTagName('a');
		var a;
		var val = '';
		for(var i = 0;i<aList.length;i++){
			if(i>0){
				val +='.';
			}
			a = aList[i];
			val+=a.getAttribute('val');
		}
		
		if(val =='...'){
			val = '';
		}
		
		return val;
	},
	setIpAValue:function(a,v){
		var val = a.getAttribute('val');
		if(val.length<3){
			val +=''+v;
		}else{
			val = ''+v;
		}
		var rv = parseInt(val,10);
		if(rv<0 ||rv >255){
			val = '';
			a.innerHTML = '&nbsp;';
		}else{
			a.innerHTML = val;
		}
		document.refresh();
		a.setAttribute('val',val);
	},
	focusIpA:function(event){
		var a = event.currentTarget;
		var par = a.parentNode.parentNode;
		var pos = a.getAttribute('pos');
		par.className ='ipContentBox'+pos;
		
		KEY.CURTYPE = 'ipbox';
	},
	blurIpA:function(event){
		
		var a = event.currentTarget;
		var pos = a.getAttribute('pos');
		var par = a.parentNode.parentNode;
		par.className ='ipContentBox';
		if(KEY.CURTYPE=='ipbox'){
			KEY.CURTYPE = '';
		}
	},
	formatSpaceKB:function(number){
	
		if(number.size<1)
		{
			return "1" + "K"
		}else if(number<1024){
			return Math.ceil(number) + "KB";
		}else if(number<1024*1024){
			return (number/(1024)).toFixed() + "K";
		}else if(number<1024*1024*1024){
			return (number/(1024*1024)).toFixed(1) + "M";
		}else
		{
			return Math.ceil(number/(1024*1024*1024)) + "G";
		}
	},
}


//显示加载点点点
var gPointLoadingTimer = null;
var gPointLoadingTimers = 0;
var gPointLoadingText = '●●●●●●●●●●';
function showGPointLoading(dom,top){
	var gPointLoadingBox = document.getElementById('gPointLoadingBox');
	if(!gPointLoadingBox){
		gPointLoadingBox =document.createElement('div');
		gPointLoadingBox.setAttribute('id','gPointLoadingBox');
		gPointLoadingBox.innerHTML ='&nbsp;';	
		var body = document.getElementsByTagName('body')[0];
		body.appendChild(gPointLoadingBox);
	}
	if(gPointLoadingTimer){clearInterval(gPointLoadingTimer);gPointLoadingTimer = null;}
	
	gPointLoadingBox.innerHTML ='';
	gPointLoadingBox.style.display = 'block';
	var l,t;
	if(typeof(dom) =='object'){
		l = dom.positionLeft;
		t = dom.positionTop + dom.offsetHeight/2 - 10;
	}else{
		l = dom;
		t = top;
	}
	
	
	gPointLoadingBox.style.left = l+'px';
	gPointLoadingBox.style.top = t+'px';
	gPointLoadingTimers = 0;
	gPointLoadingTimer = setInterval("showGPointLoadingText()",300);
}

function hideGPointLoading(){
	if(gPointLoadingTimer){clearInterval(gPointLoadingTimer);gPointLoadingTimer = null;}
	var gPointLoadingBox = document.getElementById('gPointLoadingBox');
	if(gPointLoadingBox){
		gPointLoadingBox.style.display = 'none';
	}
}

function showGPointLoadingText(){
	var str = gPointLoadingText.substring(0,gPointLoadingTimers);
	var gPointLoadingBox = document.getElementById('gPointLoadingBox');
	gPointLoadingBox.innerHTML =str;
	
	gPointLoadingTimers++;
	if(gPointLoadingTimers>10){
		gPointLoadingTimers = 0;
	}
}

//显示全局提示
var gTipTimer = null;
function showGTip(tip,time,title,pos){
	
	var gTipBox = document.getElementById('gTipBox');
	if(!gTipBox){
		gTipBox = document.createElement('div');
		gTipBox.setAttribute('id','gTipBox');
		
		var body = document.getElementsByTagName('body')[0];
		body.appendChild(gTipBox);
		
		gTipBox.innerHTML = '<div id="gTipTop">&nbsp;</div><div id="gTipContent">&nbsp;</div><div id="gTipBottom">&nbsp;</div>';
	}
	
	var gTipTop = document.getElementById('gTipTop');
	if(title){
		gTipTop.innerHTML = title+':';
	}else{
		gTipTop.innerHTML = 'Notice:';
	}
	
	var gtip = document.getElementById('gTipContent');
	if(!tip){
		gTipBox.style.display='none';
		return ;
	}
	
	gtip.innerHTML = tip;
	gTipBox.style.display='block';
	
	document.refresh();
	if(time){
		if(time <100){time = 1000 * time;}
		if(gTipTimer){clearTimeout(gTipTimer);}
		gTipTimer = setTimeout("hideGTip()",time);
	}
}

function hideGTip(){
	var gTipBox = document.getElementById('gTipBox');
	var gtip = document.getElementById('gTipContent');
	if(gTipBox){
		gTipBox.style.display='none';
		gtip.innerHTML = '';
	}
}

function initBottomKeyButton(list){
	var con = '<div class="gBtnContralBox2">';
	if(list && list.length>0){
		for(var i = 0;i<list.length;i++){
			var data = list[i];
			con += '<div class="ebtnItem">';
			con += '<div class="'+data.class+'">&nbsp;</div>';
			con += '<div id="'+data.class+'" class="etext">'+data.name+'</div>';
			con += '</div>';
		}
	}
	con += '</div>';
	
	
	var gBtnContralBox = document.getElementById('gBtnContralBox');
	gBtnContralBox.innerHTML = con;
}